<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>


<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<s:form method="post" name="Auctions_Manager" id="Auctions_Manager" action="performAuctionsOperation.htm" theme="simple">
	<input name="action" value="search" type="hidden">
	<table width="100%">
		<tbody>
			<tr>
				<td height="40" colspan="4" class="sectionheading bottom-border">
					Auctions Manager
				</td>
			</tr>
			<tr>
				<td>
					<s:actionmessage cssClass="note-red" />
					<s:actionerror cssClass="note-red" />
					<s:fielderror cssClass="note-red" />
				</td>
			</tr>
			<tr>
				<td align="left"><s:a href="showProcessClosedAuctions.htm" cssClass="navi-link">Process Closed Auctions</s:a>
			  </td>
				<td align="left"><s:a href="showAutomateProcessing.htm" cssClass="navi-link">Automate Processing</s:a>
			  </td>
				<td align="left"><s:a href="javascript: PPPCC=window.open('viewAutomateProcessingLogs.htm','AutomateProcessingLogs','status=1,resizable=1');PPPCC.focus()" cssClass="navi-link">View Log</s:a>
			  </td>
			</tr>


			<tr>
				<td align="right" class="verdana12blacknormal">
					Search for:				</td>

				<td align="left" class="verdana12blacknormal">
					<s:textfield name="terms" cssClass="Textfiled-border" value="%{terms}" size="40" />
			  </td>
				<td align="left" class="verdana12blacknormal">
					<s:select theme="simple" value="%{searchBy}" name="searchBy" list="#{'Keywords':'Keywords','Account':'Account','ID':'ID','Location':'Location','Country':'Country','Region':'Region'}"></s:select>
					<s:select theme="simple" value="%{language}" name="language" list="languagesList" headerValue="All" headerKey="All" listKey="languageCode" listValue="languageName" ></s:select>
			  </td>
				<td align="left" class="verdana12blacknormal">
					<s:submit value="Search" name="Search" type="image" action="searchAuctionsManager"
						src="../Admin-Images/search-btn.gif" theme="simple" title="Search">
							<s:param name="action" value="search"></s:param>
							<s:hidden name="action" value="search"></s:hidden>
						</s:submit>
			  </td>
			</tr>
			<tr>
				<td>
					<s:a href="showAuctionsManager.htm?init=true" cssClass="verdana11greynormal">Main</s:a>
					<s:iterator value="breadCrumbList">
										&nbsp;&gt;
										<s:if test="%{#id == categoryId}">
							<font class="verdana11greynormal"> <s:property
									value="categoryName" />
						</s:if>

						<s:else>
							<s:a cssClass="verdana11greynormal"
								href="showAuctionsManager.htm?categoryId=%{categoryId}">
								<s:property value="categoryName" />
							</s:a>
						</s:else>
					</s:iterator>
				</td>
			</tr>
			<s:iterator value="generalCategoriesList">
			<tr>
      			<td class="verdana12blacknormal" valign="top">
      			<s:hidden name="sort" value="%{sort}"></s:hidden>
      			<a href="showAuctionsManager.htm?categoryId=<s:property value="categoryId"/>" class="navi-link"><s:property value="categoryName"/>
      			(<s:property value="count"/>)</a> </td>
      		</tr>
		</s:iterator>
		</tbody>
  </table>
	<div>
		<center>
			<table>
				<tbody>
					<tr>
						<td align="left" style="width: "
							class="verdana12darkgreybold">
							<b>Sort by <a href="showAuctionsManager.htm?image=true" class="navi-link" style="cursor: pointer;" >Photo</a> |
							<a href="showAuctionsManager.htm?title=true" class="navi-link"
								style="cursor: pointer;">Title</a> | <a href="showAuctionsManager.htm?buyPrice=true" class="navi-link"
								style="cursor: pointer;">Price</a> | <a href="showAuctionsManager.htm?bidsSize=true" class="navi-link"
								style="cursor: pointer;">Bids</a> | <a href="showAuctionsManager.htm?endTime=true" class="navi-link"
								style="cursor: pointer;">Time left&nbsp;</a><a
								style="cursor: pointer;" href=""></a> </b>						</td>
					</tr>
				</tbody>
			</table>
		</center>
	</div>

	<display:table name="itemsList" pagesize="${pageSize}" cellpadding="0" cellspacing="0" requestURI="showAuctionsManager.htm" id="row" class="verdana12blacknormal">
		<display:column title="#" style="width: 5%; text-align: center" headerClass="Table-Head" property="itemId" />
		<display:column headerClass="Table-Head" style="width: 5%; text-align: center" title="Type" property="itemtype.type" />
		<display:column headerClass="Table-Head" style="width: 10%; text-align: center" title="Title" >
			<a target="_blank" class="navi-link" href="<%=path %>/showItem.htm?cid=<s:property value="#attr.row.itemId"/>&p=createAuction" title="<s:property value="#attr.row.title"/>">
				<s:property value="#attr.row.title"/>
			</a>
			<s:if test="#attr.row.giftIcon != null ">
				<s:if test="%{#attr.row.giftIcon == 'Icon_New.gif'}">
					<s:if test="%{#attr.row.newIcon == 'true'}">
						<img src="../images/<s:property value="#attr.row.giftIcon"/>" alt="New"
							title="New" border="0">
					</s:if>
				</s:if>
				<s:else>
					<img src="../images/<s:property value="#attr.row.giftIcon"/>"
						title="" border="0">
				</s:else>
			</s:if>
			<s:if test="#attr.row.HomePageFeatured == true">
				<img src="../images/featured.gif" title="Featured"
					border="0">
			</s:if>
			<s:if test="#attr.row.bids.size >= listingOptions.coolItemBids">
				<!-- bids.size >= listingOptions.coolItemBids -->
				<img src="../images/cool.gif" title="Cool" border="0">
			</s:if>
			<s:elseif test="#attr.row.bids.size >= listingOptions.hotItemBids">
				<!-- bids.size >= listingOptions.coolItemBids -->
				<img src="../images/hot.gif" title="Hot" border="0">
			</s:elseif>
			<s:if test="#attr.row.buyPrice > 0.0">
				<img src="../images/buyitnow.gif" title="Buy Now"
					border="0">
			</s:if>
		</display:column>
		<display:column headerClass="Table-Head" style="width: 10%; text-align: center" title="Fees">
			<s:property value="%{generalOptions.currency.currency}"/>
			<fmt:formatNumber pattern="##.##" type="number" maxFractionDigits="2" value="${row.transactions.amount}" minFractionDigits="2" minIntegerDigits="1" />
		</display:column>
		<display:column headerClass="Table-Head" style="width: 10%; text-align: center" title="Due">
			<s:property value="%{generalOptions.currency.currency}"/>
			<fmt:formatNumber pattern="##.##" type="number" maxFractionDigits="2" value="${row.transactions.due}" minFractionDigits="2" minIntegerDigits="1" />
		</display:column>
		<display:column headerClass="Table-Head" style="width: 10%; text-align: center" title="Photo">
			<s:if test="#attr.row.image != null">
				<img src="../servlet/ImageServlet?dto=ItemsDTO&id=<s:property value="#attr.row.itemId"/>" />
			</s:if>
			<s:else>
				<img src="../images/no_image.gif" alt="Photo">
			</s:else>
		</display:column>
		<display:column headerClass="Table-Head" style="width: 10%; text-align: center" title="Quantity" property="quantity" />
		<display:column headerClass="Table-Head" style="width: 10%; text-align: center" title="Price" >
			<fmt:formatNumber pattern="##.##" type="number" maxFractionDigits="2" value="${row.buyPrice}" minFractionDigits="2" minIntegerDigits="1" />
			<s:property value="%{generalOptions.currency.currency}"/>
		</display:column>
		<display:column headerClass="Table-Head" style="width: 5%; text-align: center" title="Bids">
			<s:property value="#attr.row.bids.size" />
		</display:column>
		<display:column headerClass="Table-Head" style="width: 10%; text-align: center" title="Time left">
			<s:if test="%{#attr.row.closed == true}">
				<b>Closed</b>
				<s:date name="#attr.row.endTime"
					format="dd/MM/yyyy hh:mm:ss" />
			</s:if>
			<s:else>
				<s:date name="#attr.row.endTime" nice="true" />
			</s:else>
		</display:column>
		<display:column>
			<tr>
				<td align="center" bgcolor="#E9E9E9" valign="middle" class="navi-link">
					<a href="closeAuction.htm?itemId=<s:property value="#attr.row.itemId"/>&closeAuction=true" class="navi-link">Close</a>
				</td>
				<td align="center" bgcolor="#E9E9E9" valign="middle">
					<input name="close_check_list" value="<s:property value="#attr.row.itemId"/>" type="checkbox">
				</td>
				<td align="center" bgcolor="#E9E9E9" valign="middle" class="navi-link">
					<a href="deleteAuction.htm?itemId=<s:property value="#attr.row.itemId"/>&deleteAuction=true" class="navi-link">Delete</a>
				</td>
				<td align="center" bgcolor="#E9E9E9" valign="middle">
					<input name="delete_check_list" value="<s:property value="#attr.row.itemId"/>" type="checkbox">
				</td>
				<td align="center" bgcolor="#E9E9E9" valign="middle" class="navi-link">
					<a href="relistAuction.htm?itemId=<s:property value="#attr.row.itemId"/>&relistAuction=true" class="navi-link">Relist</a>
				</td>
				<td align="center" bgcolor="#E9E9E9" valign="middle">
					<input name="relist_check_list" value="<s:property value="#attr.row.itemId"/>" type="checkbox">
				</td>
				<td align="center" bgcolor="#E9E9E9" valign="middle" class="navi-link">
					<a href="cancelAuction.htm?itemId=<s:property value="#attr.row.itemId"/>&cancelAuction=true" class="navi-link">Cancel Bids</a>
				</td>
				<td align="center" bgcolor="#E9E9E9" valign="middle">
					<input name="cancel_check_list" value="<s:property value="#attr.row.itemId"/>" type="checkbox">
				</td>
				<td align="center" bgcolor="#E9E9E9" valign="middle" class="navi-link">
					<s:url action="editUser" namespace="/ajax" var="edit">
						<s:param name="userId" value="%{#attr.row.id}"></s:param>
					 	<s:param name="adminaction" value="showAuctionsManager"></s:param>
					</s:url>
					<s:a href="javascript:PPPCC=window.open('%{edit}','EditUserInformation','scrollbars=yes,resizable=no');PPPCC.focus()" cssClass="navi-link">
					<s:property value="#attr.row.userId.userId" />
					</s:a>
				</td>
				<td align="left" bgcolor="#E9E9E9" class="verdana12darkgreybold"></td>
			</tr>
		</display:column>
	</display:table>
	<table>
		<tr>
			<td>
				<table>
					<tr>
						<td class="verdana12blacknormal">
							Campaigns per page
						</td>
						<td>
							<s:select cssClass="textfiled-border" onchange="document.forms[0].submit();"
							name="pageSize" list="#{'10':'10','20':'20','50':'50','100':'100'}" theme="simple"></s:select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>

<script language="JavaScript">
<!--
function Close_All() {
    Uncheck_All();
    for (var j = 1; j <= 10; j++) {
      box = eval("document.Auctions_Manager.X_Close_" + j);
      box.checked = true;
    }
}
function Relist_All() {
    Uncheck_All();
    for (var j = 1; j <= 10; j++) {
      box = eval("document.Auctions_Manager.X_Relist_" + j);
      box.checked = true;
    }
}
function Delete_All() {
    Uncheck_All();
    for (var j = 1; j <= 10; j++) {
      box = eval("document.Auctions_Manager.X_Del_" + j);
      box.checked = true;
    }
}
function CancelBids_All() {
    Uncheck_All();
    for (var j = 1; j <= 10; j++) {
      box = eval("document.Auctions_Manager.X_CancelBids_" + j);
      box.checked = true;
    }
}
function Uncheck_All() {
    for (var j = 0; j <= 10; j++) {
      box = eval("document.Auctions_Manager.delete_check_list["+j+"]");
      box.checked = false;
      box = eval("document.Auctions_Manager.close_check_list["+j+"]");
      box.checked = false;
      box = eval("document.Auctions_Manager.relist_check_list["+j+"]");
      box.checked = false;
      box = eval("document.Auctions_Manager.cancel_check_list["+j+"]");
      box.checked = false;
    }
}

function Uncheck_One_Entry() {
       box = eval("document.Auctions_Manager.delete_check_list");
      box.checked = false;
      box = eval("document.Auctions_Manager.close_check_list");
      box.checked = false;
      box = eval("document.Auctions_Manager.relist_check_list");
      box.checked = false;
      box = eval("document.Auctions_Manager.cancel_check_list");
      box.checked = false;
}

function Delete_Item(j) {
      Uncheck_One_Entry(j);
      box = eval("document.Auctions_Manager.X_Del_" +j);
      box.checked = ! box.checked;
}

function Relist_Item(j) {
      Uncheck_One_Entry(j);
      box = eval("document.Auctions_Manager.X_Relist_" +j);
      box.checked = ! box.checked;
}

function Close_Item(j) {
      Uncheck_One_Entry(j);
      box = eval("document.Auctions_Manager.X_Close_" +j);
      box.checked = ! box.checked;
}

function CancelBids_Item(j) {
      Uncheck_One_Entry(j);
      box = eval("document.Auctions_Manager.X_CancelBids_" +j);
      box.checked = ! box.checked;
}
// -->
</script>

	<table width="100%">
		<tbody>
			<tr>
				<td colspan="2" align="center" nowrap="nowrap">
					<img style="cursor: pointer;" onclick="checkAll(document.Auctions_Manager.close_check_list);" src="../Admin-Images/close-all-btn.gif" title="Close All" />

					<img style="cursor: pointer;"
						onclick="checkAll(document.Auctions_Manager.delete_check_list);" src="../Admin-Images/delete-all-btn.gif"
						title="Delete All" alt="Delete All" name="delete"/>

					<img style="cursor: pointer;"
						onclick="checkAll(document.Auctions_Manager.relist_check_list);" src="../Admin-Images/relist-all-btn.gif"
						title="Relist All" name="relist" alt="Relist All"/>
					<img style="cursor: pointer;"
						onclick="checkAll(document.Auctions_Manager.cancel_check_list);"
						src="../Admin-Images/cancel-bids-btn.gif" title="Cancel Bids" name="cancel" alt="Cancel All"/>
					<img style="cursor: pointer;"
						onclick="Uncheck_All();" src="../Admin-Images/uncheck-all-btn.gif"
						alt="Uncheck All" title="Uncheck All">				</td>
			</tr>

			<tr>
				<td align="center">
					<br>
					<s:submit value="Submit" name="Submit" type="image"
						src="../Admin-Images/submit-changes-btn.gif" theme="simple" title="Submit Changes"/>

					<img style="cursor: pointer;"
						onclick="document.getElementById('Auctions_Manager').reset();"
						src="../Admin-Images/reset-button.gif" alt="Reset" title="Reset">			  </td>
			</tr>

		</tbody>
  </table>
</s:form>